# -*- coding:utf-8 -*-
from datetime import datetime
from typing import Dict

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from loguru import logger

from scheduler.settings import settings

scheduler = AsyncIOScheduler()


async def init_scheduler():
    # config scheduler
    scheduler.configure(**settings.dict())

    logger.info("scheduler is running...")

    # schedule test
    scheduler.add_job(func=init_echo, trigger="date", next_run_time=datetime.now())
    scheduler.start()


def init_echo():
    logger.info("scheduler check ping!")


def mytask(msg: str, verbose: bool = False) -> Dict[str, str]:

    if verbose:

        print(datetime.now())

    return {"message": msg}
